package com.AUI.components
{
	import com.AUI.*;
	import com.AUI.define.style.*;
	
	import flash.display.*;
	import flash.text.*;

	/**
	 * Table cell.
	 * @author HuangMinPing
	 * @site www.AminLab.com
	 */
	public class Td extends H
	{
		/**
		 * Constructor.
		 */
		public function Td()
		{
			// init attributes
			depth = 2;
			align = true;
			
			/**************** INITCOMPLETE ****************/
			Object(this).constructor == Td && initComplete();
		}
		/**
		 * Get or set a string array that indicates the name of items of the List.
		 */
		override public function set value(variable:*):void
		{
			// remove all elements
			this.removeElements();
			// create label
			var font:FONT = drawStyle.font; 
			var textFormat:TextFormat = new TextFormat(font.family,font.size,font.color,font.bold,font.italic,font.underline,null,null,font.align);
			var item:TextField = new TextField;
			item.defaultTextFormat = textFormat;
			item.autoSize = TextFieldAutoSize.LEFT;
			item.selectable = false;
			item.text = variable.toString();
			elements.addChild(item);
			updateContentBox();
		}
		/**
		 * @private.
		 */
		override public function get value():*
		{
			return TextField(elements.getChildAt(0)).text;
		}
		/**
		 * @private.
		 */
		override protected function updateDrawStyle():void
		{
			super.updateDrawStyle();
			var font:FONT = drawStyle.font; 
			var textFormat:TextFormat = new TextFormat(font.family,font.size,font.color,font.bold,font.italic,font.underline,null,null,font.align);
			for(var i:int = 0,len:int = numElements;i < len;++i)
			{
				var e:DisplayObject = getElementAt(i);
				if(e is TextField)
				{
					TextField(e).setTextFormat(textFormat);
				}
			}
		}
	}
}